<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>CodingLife</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta property="og:type" content="website">
<meta property="og:title" content="CodingLife">
<meta property="og:url" content="https://yanfeng1022.gitee.io/blog/index.html">
<meta property="og:site_name" content="CodingLife">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="YanfengLiu">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/blog/atom.xml" title="CodingLife" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/blog/css/style.css">

<meta name="generator" content="Hexo 5.1.1"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/blog/" id="logo">CodingLife</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/blog/">Home</a>
        
          <a class="main-nav-link" href="/blog/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/blog/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="https://yanfeng1022.gitee.io/blog"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-Boost-Geometry介绍" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2020/08/24/Boost-Geometry%E4%BB%8B%E7%BB%8D/" class="article-date">
  <time datetime="2020-08-24T08:20:18.000Z" itemprop="datePublished">2020-08-24</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/blog/2020/08/24/Boost-Geometry%E4%BB%8B%E7%BB%8D/">Boost.Geometry介绍.md</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="1、常见几何对象"><a href="#1、常见几何对象" class="headerlink" title="1、常见几何对象"></a>1、常见几何对象</h1><p>#include &lt;boost/geometry.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/point_xy.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/point.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/multi_point.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/segment.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/polygon.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/multi_polygon.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/linestring.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/multi_linestring.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/box.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/ring.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/variant.hpp&gt;</p>
<p>Boost.Geometry的model有point_xy, point, multi_point, ，segment，linestring，multi_linestring, box，ring，polygon，multi_polygon, variant.</p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/models/model_point.html">model::point</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/models/model_d2_point_xy.html">[model::d2::point_xy]{.ul}</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/models/model_linestring.html">model::linestring</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/models/model_polygon.html">model::polygon</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/models/model_multi_point.html">model::multi_point</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/models/model_multi_linestring.html">model::multi_linestring</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/models/model_multi_polygon.html">model::multi_polygon</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/models/model_box.html">model::box</a>，</p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/models/model_ring.html">model::ring</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/models/model_segment.html">model::segment</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/models/model_referring_segment.html">model::referring_segment</a></p>
<p><strong>[model::point]{.ul}</strong></p>
<p>Basic point class, having coordinates defined in a neutral way.</p>
<p><em><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/models/model_point.html#geometry.reference.models.model_point.description">[Description]{.ul}</a></em></p>
<p>Defines a neutral point class, fulfilling the Point Concept. Library users can use this point class, or use their own point classes. This point class is used in most of the samples and tests of Boost.Geometry This point class is used occasionally within the library, where a temporary point class is necessary.</p>
<p><img src="media/image1.png">{width=”5.768055555555556in” height=”2.189724409448819in”}</p>
<p><strong>model::d2::point_xy</strong></p>
<p>2D point in Cartesian coordinate system</p>
<p><img src="media/image2.png">{width=”5.768055555555556in” height=”2.2738418635170605in”}</p>
<p><strong>model::linestring</strong></p>
<p>A linestring (named so by OGC) is a collection (default a vector) of points.</p>
<p><img src="media/image3.png">{width=”5.768055555555556in” height=”3.112346894138233in”}</p>
<p><strong>model::polygon</strong></p>
<p>The polygon contains an outer ring and zero or more inner rings.</p>
<p><img src="media/image4.png">{width=”5.768055555555556in” height=”4.061672134733159in”}</p>
<h1 id="2、常见算法"><a href="#2、常见算法" class="headerlink" title="2、常见算法"></a>2、常见算法</h1><p>提供的算法有：面积、长度、周长、质心、凸壳、交集（剪裁）、内（多边形中的点）、距离、包络线（边界框）、简化、变换等。</p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/area.html">[area]{.ul}</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/assign.html">assign</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/append.html">append</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/buffer.html">buffer</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/centroid.html">centroid</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/clear.html">clear</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/convert.html">[convert]{.ul}</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/convex_hull.html">convex_hull</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/correct.html">correct</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/covered_by.html">covered_by</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/crosses.html">crosses</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/densify.html">densify</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/difference.html">difference</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/discrete_frechet_distance.html">discrete_frechet_distance</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/discrete_hausdorff_distance.html">discrete_hausdorff_distance</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/disjoint.html">disjoint</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/distance.html">distance</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/envelope.html">envelope</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/equals.html">equals</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/expand.html">expand</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/for_each.html">for_each</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/intersection.html">intersection</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/intersects.html">intersects</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/is_empty.html">is_empty</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/is_simple.html">is_simple</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/is_valid.html">is_valid</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/length.html">length</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/make.html">make</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/num_geometries.html">num_geometries</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/num_interior_rings.html">num_interior_rings</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/num_points.html">num_points</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/num_segments.html">num_segments</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/overlaps.html">overlaps</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/perimeter.html">perimeter</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/relate.html">relate</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/relation.html">relation</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/reverse.html">reverse</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/simplify.html">simplify</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/sym_difference.html">sym_difference</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/touches.html">touches</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/transform.html">transform</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/union_.html">union_</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/unique.html">unique</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/within.html">within</a></p>
<p>常见的有以下几种：</p>
<p>计算面积</p>
<p>Boost::Geometry::area(obj1)</p>
<p>计算距离</p>
<p>Boost::Geometry::distance(obj1, obj2)</p>
<p>判断是否相交</p>
<p>Boost::Geometry::intersects(obj1, obj2)</p>
<p>计算交点</p>
<p>Boost::Geometry::intersection(obj1, obj2, result)</p>
<p>判断是否在box内</p>
<p>Boost::Geometry::within(obj1, obj2)</p>
<h1 id="3、boost-Geometry可以与VS的GraphicalDebugging插件可以配合使用，查看几何图形。"><a href="#3、boost-Geometry可以与VS的GraphicalDebugging插件可以配合使用，查看几何图形。" class="headerlink" title="3、boost.Geometry可以与VS的GraphicalDebugging插件可以配合使用，查看几何图形。"></a>3、boost.Geometry可以与VS的GraphicalDebugging插件可以配合使用，查看几何图形。</h1><p>在调试过程中插入断点，通过在GraphicalDebugging界面输入对象的名字就可以查看几何对象的形态。在视图中的其他窗口可以找到刚刚安装的插件的窗口，Geometry Watch，Graphical Watch，Plot Watch。</p>
<h1 id="4、几何图形的输入输出"><a href="#4、几何图形的输入输出" class="headerlink" title="4、几何图形的输入输出"></a>4、几何图形的输入输出</h1><p>DSV (Delimiter-Separated Values)</p>
<p>WKT (Well-Known Text)</p>
<p>SVG (Scalable Vector Graphics)</p>
<p>前两种是文本格式数据流，第三种是图形化输入和输出。</p>
<h1 id="5、几何图形的算术运算"><a href="#5、几何图形的算术运算" class="headerlink" title="5、几何图形的算术运算"></a>5、几何图形的算术运算</h1><p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/arithmetic/add_point.html">add_point</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/arithmetic/add_value.html">add_value</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/arithmetic/assign_point.html">[assign_point]{.ul}</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/arithmetic/assign_value.html">assign_value</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/arithmetic/cross_product_2.html">cross_product</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/arithmetic/cross_product_2_0.html">cross_product</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/arithmetic/divide_point.html">divide_point</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/arithmetic/divide_value.html">divide_value</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/arithmetic/dot_product.html">dot_product</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/arithmetic/multiply_point.html">multiply_point</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/arithmetic/multiply_value.html">multiply_value</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/arithmetic/subtract_point.html">subtract_point</a></p>
<p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/arithmetic/subtract_value.html">subtract_value</a></p>
<h1 id="6、官方示例"><a href="#6、官方示例" class="headerlink" title="6、官方示例"></a>6、官方示例</h1><p><a target="_blank" rel="noopener" href="https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/spatial_indexes/rtree_examples/index_of_polygons_stored_in_vector.html">https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/spatial_indexes/rtree_examples/index_of_polygons_stored_in_vector.html</a></p>
<p>#include &lt;boost/geometry.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/point.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/box.hpp&gt;</p>
<p>#include &lt;boost/geometry/geometries/polygon.hpp&gt;</p>
<p>#include &lt;boost/geometry/index/rtree.hpp&gt;</p>
<p>#include &lt;cmath&gt;</p>
<p>#include &lt;vector&gt;</p>
<p>#include &lt;iostream&gt;</p>
<p>#include &lt;boost/foreach.hpp&gt;</p>
<p>namespace bg = boost::geometry;</p>
<p>namespace bgi = boost::geometry::index;</p>
<p>int main()</p>
<p>{</p>
<p>typedef bg::model::point&lt;float, 2, bg::cs::cartesian&gt; point; //define point 2 dimension</p>
<p>typedef bg::model::box&lt;point&gt; box;</p>
<p>typedef bg::model::polygon&lt;point, false, false&gt; polygon; // ccw, open polygon</p>
<p>typedef std::pair&lt;box, unsigned&gt; value;</p>
<p>// polygons</p>
<p>std::vector&lt;polygon&gt; polygons;</p>
<p>// create some polygons</p>
<p>for ( unsigned i = 0 ; i &lt; 10 ; ++i )</p>
<p>{</p>
<p>// create a polygon</p>
<p>polygon p;</p>
<p>for ( float a = 0 ; a &lt; 6.28316f ; a += 1.04720f )</p>
<p>{</p>
<p>float x = i + int(10*::cos(a))*0.1f;</p>
<p>float y = i + int(10*::sin(a))*0.1f;</p>
<p>p.outer().push_back(point(x, y));</p>
<p>}</p>
<p>// add polygon</p>
<p>polygons.push_back(p);</p>
<p>}</p>
<p>// display polygons</p>
<p>std::cout &lt;&lt; &quot;generated polygons:&quot; &lt;&lt; std::endl;</p>
<p>BOOST_FOREACH(polygon const&amp; p, polygons)</p>
<p>std::cout &lt;&lt; bg::wkt&lt;polygon&gt;(p) &lt;&lt; std::endl;</p>
<p>// create the rtree using default constructor</p>
<p>bgi::rtree&lt; value, bgi::rstar&lt;16, 4&gt; &gt; rtree;</p>
<p>// fill the spatial index</p>
<p>for ( unsigned i = 0 ; i &lt; polygons.size() ; ++i )</p>
<p>{</p>
<p>// calculate polygon bounding box</p>
<p>box b = bg::return_envelope&lt;box&gt;(polygons[i]);</p>
<p>// insert new value</p>
<p>rtree.insert(std::make_pair(b, i));</p>
<p>}</p>
<p>// find values intersecting some area defined by a box</p>
<p>box query_box(point(0, 0), point(5, 5));</p>
<p>std::vector&lt;value&gt; result_s;</p>
<p>rtree.query(bgi::intersects(query_box), std::back_inserter(result_s));</p>
<p>// find 5 nearest values to a point</p>
<p>std::vector&lt;value&gt; result_n;</p>
<p>rtree.query(bgi::nearest(point(0, 0), 5), std::back_inserter(result_n));</p>
<p>// note: in Boost.Geometry the WKT representation of a box is polygon</p>
<p>// note: the values store the bounding boxes of polygons</p>
<p>// the polygons aren&#39;t used for querying but are printed</p>
<p>// display results</p>
<p>std::cout &lt;&lt; &quot;spatial query box:&quot; &lt;&lt; std::endl;</p>
<p>std::cout &lt;&lt; bg::wkt&lt;box&gt;(query_box) &lt;&lt; std::endl;</p>
<p>std::cout &lt;&lt; &quot;spatial query result:&quot; &lt;&lt; std::endl;</p>
<p>BOOST_FOREACH(value const&amp; v, result_s)</p>
<p>std::cout &lt;&lt; bg::wkt&lt;polygon&gt;(polygons[v.second]) &lt;&lt; std::endl;</p>
<p>std::cout &lt;&lt; &quot;knn query point:&quot; &lt;&lt; std::endl;</p>
<p>std::cout &lt;&lt; bg::wkt&lt;point&gt;(point(0, 0)) &lt;&lt; std::endl;</p>
<p>std::cout &lt;&lt; &quot;knn query result:&quot; &lt;&lt; std::endl;</p>
<p>BOOST_FOREACH(value const&amp; v, result_n)</p>
<p>std::cout &lt;&lt; bg::wkt&lt;polygon&gt;(polygons[v.second]) &lt;&lt; std::endl;</p>
<p>return 0;</p>
<p>}</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://yanfeng1022.gitee.io/blog/2020/08/24/Boost-Geometry%E4%BB%8B%E7%BB%8D/" data-id="cke89le600000xoum39qvg7j1" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-myFirstBlog" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2020/08/24/myFirstBlog/" class="article-date">
  <time datetime="2020-08-24T07:42:33.000Z" itemprop="datePublished">2020-08-24</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/blog/2020/08/24/myFirstBlog/">myFirstBlog</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="head1"><a href="#head1" class="headerlink" title="head1"></a>head1</h1><h2 id="head2"><a href="#head2" class="headerlink" title="head2"></a>head2</h2><h3 id="head3"><a href="#head3" class="headerlink" title="head3"></a>head3</h3><p>这是我的第一次用hexo写博客，部署到gitee.com</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://yanfeng1022.gitee.io/blog/2020/08/24/myFirstBlog/" data-id="cke89le6d0002xoumhyt55myr" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-hello-world" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2020/08/24/hello-world/" class="article-date">
  <time datetime="2020-08-24T06:14:24.281Z" itemprop="datePublished">2020-08-24</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/blog/2020/08/24/hello-world/">Hello World</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>Welcome to <a target="_blank" rel="noopener" href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a target="_blank" rel="noopener" href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a target="_blank" rel="noopener" href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a target="_blank" rel="noopener" href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">&quot;My New Post&quot;</span></span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://yanfeng1022.gitee.io/blog/2020/08/24/hello-world/" data-id="cke89le660001xoumbnpqhu8c" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  


</section>
        
          <aside id="sidebar">
  
    

  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/08/">August 2020</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/blog/2020/08/24/Boost-Geometry%E4%BB%8B%E7%BB%8D/">Boost.Geometry介绍.md</a>
          </li>
        
          <li>
            <a href="/blog/2020/08/24/myFirstBlog/">myFirstBlog</a>
          </li>
        
          <li>
            <a href="/blog/2020/08/24/hello-world/">Hello World</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 YanfengLiu<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/blog/" class="mobile-nav-link">Home</a>
  
    <a href="/blog/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/blog/fancybox/jquery.fancybox.css">

  
<script src="/blog/fancybox/jquery.fancybox.pack.js"></script>




<script src="/blog/js/script.js"></script>




  </div>
</body>
</html>